import cv2

cap = cv2.VideoCapture(0)
save_id = 1

while 1:
    flag,image = cap.read()

    if not flag:
        print("no image,please try check cammear")

    cv2.imshow("image",image)
    key = cv2.waitKey(1)
    if key==ord("q"):
        break
    elif key==ord("s"):
        cv2.imwrite(f"train/{save_id}.jpg",image)
        print(f"train/{save_id}.jpg have saved")
        save_id += 1
cap.release()
cv2.destroyAllWindows()
